package sunstar.com.xq.adapter

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import com.squareup.picasso.Picasso
import sunstar.com.xq.R

/**
 * Created by Sun.Star on 2017/6/13.
 */
class ImageAdapter(var context: Context,var mutableList: MutableList<String>) : RecyclerView.Adapter<ImageAdapter.ImageViewHolder>() {
    override fun onBindViewHolder(holder: ImageViewHolder?, position: Int) {
        Picasso.with(context).load(mutableList[position]).into(holder!!.imageView)
    }

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ImageViewHolder
    = ImageViewHolder(LayoutInflater.from(context).inflate(R.layout.image_adapter,parent,false))

    override fun getItemCount(): Int = mutableList.size


    class ImageViewHolder (itemview:View): RecyclerView.ViewHolder(itemview){
        var imageView:ImageView?=null
        init {
            imageView = itemview.findViewById(R.id.image_view) as ImageView
        }

    }
}